using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms; using Montana.Entidades;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class frmReporte : Form
{
    public frmReporte()
    {
        InitializeComponent();
    }

    static frmReporte instancia;
    public static frmReporte Instancia
    {
        get
        {
            if (instancia == null)
                instancia = new frmReporte();

            return instancia;
        }
        set
        {
            instancia = value;
        }
    }

    public ReportClass SetearConexionReporte(ReportClass reporte)
    {
        Database db;
        Tables tablas;
        TableLogOnInfo logInfo;
        ConnectionInfo cnnInfo;

        cnnInfo = new ConnectionInfo();
        cnnInfo.ServerName = @"x2\sqlexpress";
        cnnInfo.DatabaseName = "veterinaria";
        cnnInfo.UserID = "sa";
        cnnInfo.Password = "lovecraft";

        db = reporte.Database;
        tablas = db.Tables;

        foreach (Table t in tablas)
        {
            logInfo = t.LogOnInfo;
            logInfo.ConnectionInfo = cnnInfo;
            t.ApplyLogOnInfo(logInfo);
        }

        return reporte;
    }

    private void frmReporte_Load(object sender, EventArgs e)
    {
        Instancia = this;
    }

//Public Function SetearConexionReporte(ByVal Reporte As ReportClass) As ReportClass
//    '***
//    'Recibe un reporte (dimensionado asi: Dim Reporte as New rptNombreReporte) y 
//    'le carga los datos de conexion
//    '***
//    Dim Database As Database
//    Dim Tables As Tables
//    Dim Table As Table
//    Dim TableLogOnInfo As TableLogOnInfo
//    Dim ConnectionInfo As ConnectionInfo

//    ConnectionInfo = New ConnectionInfo()
//    With ConnectionInfo
//        .ServerName = "127.0.0.1"
//        .DatabaseName = "bus"
//        .UserID = "sa"
//        .Password = "cd"
//    End With

//    Database = Reporte.Database
//    Tables = Database.Tables

//    For Each Table In Tables
//        TableLogOnInfo = Table.LogOnInfo
//        TableLogOnInfo.ConnectionInfo = ConnectionInfo
//        Table.ApplyLogOnInfo(TableLogOnInfo)
//    Next

//    Return Reporte
//End Function
}